/*
 * @Description: 
 * @Author: fhw
 * @Date: 2022-12-05 15:04:34
 */
import { ApiProperty } from "@nestjs/swagger";
import { ChatUser } from "src/chat_user/entities/chat_user.entity";
import { Entity, Column, PrimaryGeneratedColumn, UpdateDateColumn, CreateDateColumn, JoinColumn, ManyToOne, OneToMany } from "typeorm";

/*
 * @Description: 
 * @Author: fhw
 * @Date: 2022-12-05 15:04:34
 */
@Entity('message_board')
export class MessageBoard {
    @ApiProperty({ example: 'id', description: 'id' })
    @PrimaryGeneratedColumn({
        type: 'int',
        comment: 'id',
    })
    id: number;

    @ApiProperty({ example: 'content', description: '留言内容' })
    @Column({
        type: 'text',
        comment: '留言内容',
    })
    content: string;

    @ApiProperty({ example: 'date', description: '创建时间' })
    @CreateDateColumn({
        type: 'datetime',
        comment: '创建时间',
    })
    createDate: string;

    @ApiProperty({ example: 'updateDate', description: '更新时间' })
    @UpdateDateColumn({
        type: 'datetime',
        comment: '更新时间',
    })
    updateDate: string;

    @ApiProperty({ example: 'userId', description: '用户ID' })
    @Column({
        type: 'int',
        comment: '用户ID',
    })
    userId: number;
    @ManyToOne(() => ChatUser, (user) => user.id)
    @JoinColumn({ name: 'userId' })
    user: ChatUser;

    @ApiProperty({ example: 'toUserId', description: '被回复用户id' })
    @Column({
        type: 'int',
        comment: '被回复用户id',
        nullable: true

    })
    toUserId: number;
    @ManyToOne(() => ChatUser, (user) => user.id)
    @JoinColumn({ name: 'toUserId' })
    toUser: ChatUser;

    @ApiProperty({ example: 'messageBoardId', description: '留言ID' })
    @Column({
        type: 'int',
        comment: '留言ID',
        nullable: true

    })
    messageBoardId: number;
    @ManyToOne(() => MessageBoard, (messageBoard) => messageBoard.id)
    @JoinColumn({ name: 'messageBoardId' })
    messageBoard: MessageBoard;

    @ApiProperty({ example: 'twoMessageBoard', description: '留言' })
    @OneToMany(() => MessageBoard, (messageBoard) => messageBoard.messageBoard)
    twoMessageBoard?: MessageBoard[]
}